package web.tag;

import domain.Club;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import java.text.SimpleDateFormat;

/**
 * activity详细信息展示标签
 * 结合modal实现activity的详细信息的展示
 *
 * @author shicm
 */
public class ShowClubInfoTag extends SimpleTagSupport {

    /** 要展示的社团 */
    private Club club;

    /**
     * 设置要展示的社团
     *
     * @param club 社团
     */
    public void setClub(Club club) {
        this.club = club;
    }

    /**
     * 展示社团详细信息
     *
     * @throws JspException JSP异常
     * @throws IOException IO异常
     */
    @Override
    public void doTag() throws JspException, IOException {
        JspWriter out = getJspContext().getOut();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String outPrint = "";
        outPrint += "<p><span class=\"fw-semibold\">社团ID: &nbsp;&nbsp;</span>"+club.getClubID()+"</p>";
        outPrint += "<p><span class=\"fw-semibold\">社团名称: &nbsp;&nbsp;</span>"+club.getClubName()+"</p>";
        outPrint += "<p><span class=\"fw-semibold\">所属学院: &nbsp;&nbsp;</span>"+club.getCollege()+"</p>";
        outPrint += "<p><span class=\"fw-semibold\">社团介绍: &nbsp;&nbsp;</span>"+club.getDescription()+"</p>";
        outPrint += "<p><span class=\"fw-semibold\">创建时间: &nbsp;&nbsp;</span>"+sdf.format(club.getCreateTime())+"</p>";
        out.write(outPrint);
    }
}
